home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / bathints.zip / BH_11.DOC < prev    next >
Text File  |  1988-11-03  |  11KB  |  214 lines

  1.  
  2.                                   BAT-HINT # 11
  3.  
  4. **************************************************************************
  5.  
  6. from the BATHINTS library... part of the BATPOWER CONFERENCE from:
  7.  
  8.                          THE PAINFRAME OPUS/FIDO 261/1004
  9.  
  10.                         Baltimore, Maryland 1-301-488-7461
  11.  
  12. **************************************************************************
  13.  
  14.  
  15.                      COMMAND.COM ...The Final Treatise?
  16.  
  17.      Command.com is an executable program just like all other .com
  18. files in DOS. Running the "command" command invokes a secondary command
  19. processor, using up about 2 to 4 Kbytes of RAM, depending on the
  20. version of DOS that you employ. There are several optional command.com
  21. parameters in DOS 3.x:
  22.  
  23.      /p   will permanently (until reboot) load the secondary command   
  24.           processor
  25.      /c   allows you to pass a string to the secondary command
  26.           processor
  27.      /e   sets the environment size
  28.      /f   nullifys the ABORT, RETRY, FAIL statement
  29.      /d   disables execution of autoexec.bat
  30.  
  31. Not all of these optional parameters are used on the command line
  32. itself and only the /c parameter is used extensively.  I addition, you
  33. should be aware that many third-party DOSs may use these parameters in
  34. different ways and may also offer other parameters to control the
  35. behaviour of command.com.
  36.  
  37.      The /p parameter finds its greatest use when employed in the
  38. config.sys file to expand the environment. For example:
  39.  
  40.     shell=command.com /e:62 /p            [DOS 3.1] or
  41.     shell=command.com /e:32768 /p         [DOS 3.2 & 3.3]
  42.  
  43. will expand the environment to the maximum 992 bytes allowable in DOS
  44. 3.1 (62 x 16 = 992) or 32768 bytes in DOS 3.2 or 3.3. This is very
  45. useful when long paths, many environmental variables or programs
  46. employing user defined environmental variables are used.  The value
  47. used in DOS 3.1 is specified in increments of 16 bytes and defaults to
  48. a value of 10 (160 bytes) if the /e parameter is omitted.  The same 160
  49. byte default value is used in higher versions of DOS, but the value
  50. entered is in bytes rather than in 10 byte increments.  Setting a value
  51. for the /e parameter below 160 is ignored by DOS 3.2 or 3.3 and is
  52. reset to 160.
  53.  
  54.      When command.com is run without any parameters, the new command
  55. processor embraces the environment of the previous command processor.
  56. So expanding the environment by issuing one of the config.sys commands
  57. shown above will also result in an expanded environment in any
  58. subsequent command processor.  Although any environmental variables
  59. defined in the primary command processor's environment (i.e. path,
  60. prompt, etc.) will be retained in the secondary command processor's
  61. environment, the size of this environment will be limited to that
  62. required to embrace the previously defined variables and fill out that
  63. paragraph of memory, depending on the version of DOS employed and the
  64. manner in which the "set" command is issued for defining new variables
  65. in the secondary command processor's environment. In DOS 3.1 the
  66. increased environment size is lost beyond that required to retain those
  67. variables that have been defined, but in higher versions of DOS  the
  68. size of the expanded environment is retained for the definition of
  69. variables using the "set" command from the command line... but not from
  70. within batch files.  One further point is that in the higher versions
  71. of DOS the /e parameter can be used when the secondary command
  72. processor is invoked, allowing for even greater control over the size
  73. of the seconadary command processor's environment.
  74.  
  75.      In all DOS 3.x versions, any variables defined in the secondary
  76. command processor's environment are lost when the "exit" command is
  77. issued to return to the primary command processor.  This latter point
  78. is usefull for quickly and temporarily changing the value of the path
  79. variable for special applications or purposes, since upon returning to
  80. the primary command processor the original value of the variable is
  81. restored. Thus, if you normally employ a long path but occasionally
  82. want to modify the path for a special application, you need only enter
  83.  
  84.      command
  85.      set path=[your new path]
  86.  
  87. to invoke a new path in the secondary command processor. All other
  88. environmental variables will remain the same. To return to the original
  89. command processor, just type
  90.  
  91.      exit
  92.  
  93. at the DOS prompt. Your original path will be intact.
  94.  
  95.      Their are several methods of calling a batch file from within a
  96. running batch file.  Simply naming the batch file to be executed (and
  97. the drive and subdirectory location of the batch file if the location
  98. of that batch file is not included in the path variable), will
  99. successfully execute the second batch file.  This method however, will
  100. result in the termination of the first batch file since processing is
  101. not returned to the original batch file when a second batch file is
  102. called.  Nonetheless, this is a usefull way of chaining batch files
  103. when a return to the original batch file is unwanted, such as in the
  104. case where a user selection is made that causes the first batch file to
  105. "goto" a line that executes another batch  file.
  106.  
  107.      The command /c command is used for calling a batch file from
  108. another batch file when one desires that the commands in the first
  109. batch file be completed.  To call another batch file from within a
  110. batch file in DOS 3.1 enter the following line in the first batch file:
  111.  
  112.      command /c batname
  113.  
  114. BATNAME.bat will be executed and will return to the next line in the
  115. original bat file. Alternatively, you could enter
  116.  
  117.      command batname
  118.  
  119. Again, BATNAME will be executed... but this time reentry into the first
  120. bat file is accomplished with the EXIT command. The EXIT command could
  121. be placed at the end of the second bat file or at some other location
  122. in the second bat file executable upon a conditional statement.
  123.  
  124.      In DOS versions higher than 3.1, the command /c command for
  125. calling a batch file from within a batch file can be replaced with the
  126. DOS internal command "call".  The call command performs essentially the
  127. same task as the command /c command but does not invoke a secondary
  128. command processor and thus saves you the memory required by the
  129. previous method.  To call a second batch file and return to the intila
  130. batch file using the "call" command, you could enter:
  131.  
  132.      call batname
  133.  
  134. As described above for the command command, BATNAME will be executed...
  135. with no need for an exit command since a secondary command processor
  136. was not invoked.
  137.  
  138.      Very few files, including command.com, need be present in the root
  139. directory of your hard disk or floppy boot disk.  Indeed, the only
  140. files in the root should be config.sys and autoexec.bat (if you choose
  141. to even have an autoexec.bat).  Be carefull of programs that absolutely
  142. demand that command.com be in the root dir of the boot disk, however. 
  143. So how does one place command.com in a directory other than the root
  144. directory? the directory it was intended to be placed (i.e. the DOS
  145. subdirectory)?  Enter the following line in the config.sys file:
  146.  
  147.      shell=c:\dos\command.com c:\dos
  148.  
  149. The config line shown above assumes that you have a hard disk and that
  150. command.com resides in a subdirectory called DOS.  You could of course
  151. place it anywhere you like, so long as you include the path and follow
  152. the statement with the path again.  For example, if you booted from a
  153. floppy and had placed command.com in a:\util\msdos, you would include
  154. the following line in the config.sys file:
  155.  
  156.      shell=a:\util\msdos\command.com a:\util\msdos
  157.  
  158. Naturally, you may place any of the parameters mentioned above after
  159. this statement.  For example, if you booted from a hard disk and your
  160. only copy of command.com was in the subdirectory MSDOS and you wanted
  161. to expand your environment space to 2500 bytes, you would change the
  162. line to read:
  163.  
  164.      shell=c:\msdos\command.com c:\msdos /e:2500
  165.  
  166. Even though you may decide to employ a shell statement as above, you
  167. can still improve things.  You could for example, pl